home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
batch
/
bbb_v21
/
bet.doc
< prev
next >
Wrap
Text File
|
1991-11-25
|
7KB
|
255 lines
-- BET v1.0 --
Brent's Environment Tools
(c) 1991 Brent Ashley
BET is a collection of tools to allow you to manipulate the DOS
environment variables as strings and long integers. BET also
provides system information functions which assign their results
to either environment variables or DOS ERRORLEVELs (or both) to
assist you in building powerful batches, with emphasis on install
batches. BET was written as a companion program to Brent's Batch
Beautifier (BBB), and is distributed with it.
Full source is now included for those who are interested.
Microsoft QuickBASIC v 4.0 or later and Crescent Software's
PDQ version 2.16 or later are required to recompile the source.
Repeated calls to BET load it from disk each time, so you may want
to ensure you use a disk caching program or copy BET and BBB to a
RAM disk for faster access.
BET has two syntax forms, as shown below, from BET's own help
screen. The /D switch causes the environment variables and
ERRORLEVELs returned by the functions to be displayed, making for
easy debugging.
Syntax: BET [/D] ResultVar Action [Value1 [Value2...]]
or: BET [/D] IS Value1 LT/GT/LE/GE/EQ/NE Value2
(returns ERRORLEVEL 255=True 0=False)
We'll start with the second form, which is for numerical
comparisons.
The IS keyword allows you to make comparisons between numerical
values using the following operators:
LT - less than
GT - greater than
LE - less than or equal to
GE - greater than or equal to
EQ - equal to
NE - not equal to
BET returns a DOS ERRORLEVEL of 0 for FALSE and 255 for TRUE
Example: Check if environment variable Count is less than 20 and
transfer control to :Top if so.
BET IS %Count% LT 20
IF ErrorLevel 255 GOTO Top
The other form of the BET command is the Action form, which allows
you many choices. Only one action (and its parameters) is allowed
per line, however, since enviroment variables and/or ERRORLEVELs
need to be set for each action.
Syntax: BET [/D] ResultVar Action [Value1 [Value2...]]
ResultVar is the name of the environment variable to which you
want the result of the action assigned, and Action is one of the
choices listed below.
If a variable named DUMMY is used for ResultVar, no environment
variable is created or changed. ResultVar cannot be called "IS"
due to the IS comparison keyword.
Math actions:
-------------
(&H and &O prefixes can be used for Hex and Octal numbers
eg: &HFF is the same as 255.)
HEX Value1
- assigns the hexadecimal value of Value1 to ResultVar
Example: BET ThreeK HEX 3072
Gives: ThreeK=C00
ADD/SUB/MUL/DIV/MOD Value1 Value2
- performs mathematical function on two integer values.
- read as though function symbol is between values:
Example: BET Length DIV %Area% %Width%
Gives : Length = Area / Width
Example: BET Test MOD 123 100
Gives : 123 MOD 100
= 23
String actions:
---------------
TargetVar is the variable upon which to perform the action.
TargetVar and ResultVar can be the same variable.
LEFT/RIGHT TargetVar Characters
- assigns a number of characters from left or right of TargetVar to
ResultVar
MID TargetVar Startpos Characters
- assigns a number of characters from middle of TargetVar to
ResultVar
Example: SET BracketedLetter=(A)
BET Letter MID %BracketedLetter% 2 1
Gives: BracketedLetter=(A)
Letter=A
LEN TargetVar
- returns length of TargetVar as integer in ResultVar
and as DOS ERRORLEVEL
UPPER/LOWER TargetVar
- Assigns TargetVar to ResultVar and forces all upper- or lower-case
on ResultVar
LTRIM/RTRIM TargetVar
- trims spaces from left or right of TargetVar and assigns result
to ResultVar
INSTR TargetVar Text
- returns position of Text in TargetVar as integer in ResultVar
and as DOS ERRORLEVEL
- use tilde ~ character in Text in place of spaces
APPEND Text
- appends Text to end of ResultVar
(this is mostly useful at the command line, to add a directory
to your PATH)
System info actions:
--------------------
CPU
- returns type of CPU installed (or equivalent eg. NEC V20 = 86)
ResultVar : 86, 286, or 386
ERRORLEVEL: 1, 2, or 3
VIDEO
- Returns type of video adapter installed as per chart:
ResultVar ErrorLevel
-----------------------
Monochrome 1
Hercules 2
CGA 3
EGA 4
VGA 5
MCGA 6
8514/A 7
COLOR
- returns whether color monitor is being used
ResultVar : YES, NO
ERRORLEVEL: 255, 0
MACHINEID
- returns Machine Identification byte as hex number in ReturnVar
NPX
- returns whether numeric processor extension (coprocessor) is
installed.
ResultVar : YES, NO
ERRORLEVEL: 255, 0
MOUSE
- returns whether mouse driver is installed
ResultVar : YES, NO
ERRORLEVEL: 255, 0
SERIAL/PARALLEL
- returns number of serial or parallel ports installed in ResultVar
and as DOS ERRORLEVEL
TIME
- assigns formatted time (eg 12:00am) to ResultVar
HOUR/MINUTE
- returns hour (0-23) or minute (0-59) in ResultVar
and as DOS ERRORLEVEL
DATE
- Returns date in mm/dd/yy format in ResultVar
WEEKDAY
- Returns text (eg Monday) in ResultVar
and number (0=Sunday to 6=Saturday) as DOS ERRORLEVEL
DAY
- returns day of month in ResultVar
and as DOS ERRORLEVEL
MONTH
- returns text (eg January) in ResultVar
and number (1-12) as DOS ERRORLEVEL
YEAR
- returns 4-digit year in ResultVar
and 2-digit year as DOS ERRORLEVEL
DOSVER
- returns DOS version in format X.XX in ResultVar
and in format XX (eg 33 or 50) as DOS ERRORLEVEL
MODE
- returns current video mode in ResultVar and as DOS ERRORLEVEL
LINES
- returns current number of screen lines in ResultVar
and as DOS ERRORLEVEL
CURDRIVE
- returns currently logged drive letter in ResultVar
and number (A=1 to Z=26) as DOS ERRORLEVEL
CURDIR
- returns currently logged path (eg \DOS) in ResultVar
VALIDDRVS
- returns string of valid drives (eg ABCNY) in ResultVar
MEM
- returns amount of installed conventional memory in ResultVar
EXT
- returns amount of available extended memory in ResultVar
VOL DriveLetter
- returns volume label of specified drive in ResultVar
TOGGLE CAP/NUM/INS/SCR [ON/OFF]
- without ON or OFF reports status of lock keys
ResultVar : YES, NO
ERRORLEVEL: 255, 0
Example: BET CapOn TOGGLE CAP
- ON and OFF set and clear lock status. Older XT keyboards may not
update their LEDs properly after such a change.
-- Revision History --
1.0 - first release 25 August 1991
- released with source 25 November 1991
-- Note --
BET and BBB are distributed as Freeware. This means that while anyone can
use them at no cost in a personal, business, or government environment, I
retain the copyright.
Both programs were written in Microsoft QuickBASIC and linked with
Crescent Software's PDQ link library.
Brent Ashley
8 Darnock Court
Brampton, Ontario
L6Z 2X3
CANADA